<template>
	<view class="content" :data-theme="themeStyle">
		<view class="head-wrap">
			<!-- 搜索区域 -->
			<view class="search-wrap uni-flex uni-row">
				<view class="flex-item input-wrap">
					<input class="uni-input" maxlength="50" v-model="keyword" confirm-type="search" @confirm="search()" placeholder="请输入您要搜索的商品" />
					<text class="iconfont iconIcon_search" @click.stop="search()"></text>
				</view>
			</view>

			<!-- 排序 -->
			<view class="sort-wrap">
				<view class="comprehensive-wrap" :class="{ 'ns-text-color': orderType === '' }" @click="sortTabClick('')">
					<text :class="{ 'ns-text-color': orderType === '' }">综合</text>
				</view>
				<view :class="{ 'ns-text-color': orderType === 'sale_num' }" @click="sortTabClick('sale_num')">销量</view>
				<view class="price-wrap" @click="sortTabClick('discount_price')">
					<text :class="{ 'ns-text-color': orderType === 'discount_price' }">价格</text>
					<view class="iconfont-wrap">
						<view class="iconfont iconiconangledown-copy" :class="{ 'ns-text-color': priceOrder === 'asc' && orderType === 'discount_price' }"></view>
						<view class="iconfont iconiconangledown" :class="{ 'ns-text-color': priceOrder === 'desc' && orderType === 'discount_price' }"></view>
					</view>
				</view>
				<view :class="{ 'ns-text-color': orderType === 'screen' }" class="screen-wrap">
					<view class="iconfont ns-font-size-lg" :class="{ iconapps: isList, iconlist1: !isList }" @click="changeListStyle()"></view>
					<text style="padding: 0 14rpx; color: #E3E3E3;">|</text>
					<text  @click="sortTabClick('screen')">筛选</text>
					<view  @click="sortTabClick('screen')" class="iconfont-wrap"><view class="iconfont iconshaixuan ns-text-color-gray"></view></view>
				</view>
			</view>
		</view>

		<!-- top:350 -->
		<mescroll-uni top="180" ref="mescroll" @getData="getGoodsList">
			<block slot="list">
				<view class="goods-list" :class="listStyle" v-if="isList">
					<ns-goods-item-row :value="goodsList" @toDetail="navToDetailPage"></ns-goods-item-row>
				</view>
				<view v-else>
					<ns-goods-item-col :value="goodsList" @toDetail="navToDetailPage"></ns-goods-item-col>
				</view>
				<view v-if="goodsList.length == 0 && emptyShow"><ns-empty></ns-empty></view>
			</block>
		</mescroll-uni>
		<!-- 筛选弹出框 -->
		<uni-drawer :visible="showScreen" mode="right" @close="showScreen = false" class="screen-wrap">
			<view class="title ns-text-color-gray">筛选</view>
			<scroll-view scroll-y>
				<!-- 包邮 -->
				<view class="item-wrap">
					<view class="label"><text>是否包邮</text></view>
					<view class="list"><uni-tag :inverted="true" text="包邮" :type="isFreeShipping ? 'primary' : 'default'" @click="isFreeShipping = !isFreeShipping" /></view>
				</view>
				<!-- 价格筛选项 -->
				<view class="item-wrap">
					<view class="label"><text>价格区间(元)</text></view>
					<view class="price-wrap">
						<input class="uni-input" type="digit" v-model="minPrice" placeholder="最低价" />
						<view class="h-line"></view>
						<input class="uni-input" type="digit" v-model="maxPrice" placeholder="最高价" />
					</view>
				</view>
				<!-- 分类 -->
				<view class="category-list-wrap">
					<text class="first">全部分类</text>
					<view class="class-box">
						<view @click="selectedCategory('')" class="list-wrap">
							<text :class="{ 'selected': !categoryId , 'ns-text-color': !categoryId }">
								全部
							</text>
						</view>
						<view @click="selectedCategory(item.category_id, item.level)" v-for="(item, index) in categoryList" :key="index" class="list-wrap">
							<text :class="{ 'selected': item.category_id == categoryId , 'ns-text-color': item.category_id == categoryId }">
								{{ item.category_name }}
							</text>
						</view>
					</view>
				</view>
			</scroll-view>
			<view class="footer" :class="{ 'safe-area': isIphoneX }">
				<!-- <view class="footer-box" @click="showScreen = false">取消</view> -->
				<view class="footer-box" @click="resetData">重置</view>
				<view class="footer-box1 ns-bg-color" @click="screenData">确定</view>
			</view>
		</uni-drawer>
		<loading-cover ref="loadingCover"></loading-cover>
		<ns-show-toast></ns-show-toast>
	</view>
</template>

<script>
import uniDrawer from '@/components/uni-drawer/uni-drawer.vue';
import nsGoodsItemRow from '@/components/ns-goods-item/ns-goods-item-row.vue'
import nsGoodsItemCol from '@/components/ns-goods-item/ns-goods-item-col.vue'
import uniTag from '@/components/uni-tag/uni-tag.vue';
import list from '../public/js/list.js';
import globalConfig from '@/common/js/golbalConfig.js';
import nsShowToast from '@/components/ns-show-toast/ns-show-toast.vue'

export default {
	components: {
		uniDrawer,
		uniTag,
		nsGoodsItemCol,
		nsGoodsItemRow,
		nsShowToast
	},
	data() {
		return {};
	},
	mixins: [list, globalConfig]
};
</script>

<style lang="scss">
@import '../public/css/list.scss';
</style>
<style scoped>
	>>>.uni-tag--primary.uni-tag--inverted{
		background-color: #f5f5f5 !important;
	}
</style>
